{% extends "base_generic.html" %}

{% block content %}

<h1>Author: {{ author }} </h1>
<p>{{author.date_of_birth}} - {% if author.date_of_death %}{{author.date_of_death}}{% endif %}</p>

<div style="margin-left:20px;margin-top:20px">
<h4>Books</h4>

<dl>
{% for book in author.book_set.all %}
  <dt><a href="{% url 'book-detail' book.pk %}">{{book}}</a> ({{book.bookinstance_set.all.count}})</dt>
  <dd>{{book.summary}}</dd>
  {% empty %}
  <p>This author has no books.</p>
{% endfor %}
</dl>

</div>
{% endblock %}

{% block sidebar %}
  {{ block.super }}

  {% if perms.catalog.change_author or perms.catalog.delete_author %}
  <hr>
  <ul class="sidebar-nav">
    {% if perms.catalog.change_author %}
      <li><a href="{% url 'author-update' author.id %}">Update author</a></li>
    {% endif %}
    {% if not author.book_set.all and perms.catalog.delete_author %}
      <li><a href="{% url 'author-delete' author.id %}">Delete author</a></li>
    {% endif %}
    </ul>
  {% endif %}

{% endblock %}
